<#if ctrl.getPortletType() != 'CONTAINER'>
<#ibizinclude>../@MACRO/CONTROL/LANGBASE.vue.ftl</#ibizinclude>
<#assign import_block>
import { Environment } from '@/environments/environment';
import UIService from '@/uiservice/ui-service';
</#assign>
<#ibizinclude>
../@MACRO/CONTROL/CONTROL_HEADER-BASE.vue.ftl
</#ibizinclude>

    /**
     * 长度
     *
     * @type {number}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
    @Prop() public height?: number;

    /**
     * 宽度
     *
     * @type {number}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
    @Prop() public width?: number;

    /**
     * 门户部件类型
     *
     * @type {number}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public portletType: string = '<#if ctrl.getPortletType?? && ctrl.getPortletType()??>${ctrl.getPortletType()?lower_case}</#if>';

    /**
     * 界面行为模型数据
     *
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public uiactionModel: any = {
    <#if ctrl.getPSUIActionGroup?? && ctrl.getPSUIActionGroup()?? && ctrl.getPSUIActionGroup().getPSUIActionGroupDetails()??>
    <#assign UIActionDetails=ctrl.getPSUIActionGroup().getPSUIActionGroupDetails() />
        <#list UIActionDetails as uiactiondetail>
        <#if uiactiondetail.getPSUIAction()??>
          <#assign uiaction = uiactiondetail.getPSUIAction() />
            <#if uiaction.getCodeName?? && uiaction.getCodeName()??>
              <#assign uiactionname = uiaction.getCodeName()?lower_case />
            <#else>
              <#assign uiactionname = uiactiondetail.getName()?lower_case />
            </#if>
        ${uiactionname}: {name: '${uiactionname}', actiontarget: '${uiaction.getActionTarget()}', <#if uiactiondetail.isShowCaption()>caption: '<#if uiactiondetail.caption??>${uiactiondetail.caption}</#if>',</#if> disabled: false, type: '<#if uiactiondetail.getDetailType?? && uiactiondetail.getDetailType()??>${uiactiondetail.getDetailType()}</#if>', visabled: true, noprivdisplaymode: <#if uiaction.getNoPrivDisplayMode(view)??>${uiaction.getNoPrivDisplayMode(view)}</#if>, dataaccaction: '<#if uiaction.getDataAccessAction()??>${uiaction.getDataAccessAction()}</#if>', uiaction: { tag: '${uiaction.getUIActionTag()}', target: '${uiaction.getActionTarget()}' } },
        </#if>
        </#list>
    </#if>
    }

    <#if ctrl.getPortletType() == 'ACTIONBAR'>
    /**
     * 操作栏模型数据
     *
     * @returns {any[]}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public actionBarModelData:any[] =[
        <#if  ctrl.getPSAppViewLogics?? && ctrl.getPSAppViewLogics()??>
        <#list ctrl.getPSAppViewLogics() as appViewLogic>
        { viewlogicname:"${appViewLogic.name}",
        <#if appViewLogic.getPSAppViewUIAction?? && appViewLogic.getPSAppViewUIAction()??>
        <#assign viewUIAction = appViewLogic.getPSAppViewUIAction()/>
        <#if viewUIAction.getPSUIAction?? && viewUIAction.getPSUIAction()??>
        <#assign uiaction = viewUIAction.getPSUIAction() />
        text: "${uiaction.getCaption()}",
        iconcls: <#if uiaction.getIconCls()??>"${uiaction.getIconCls()}"<#else>null</#if>,
        icon: <#if uiaction.getIconPath()??>"${uiaction.getIconPath()}"<#else>null</#if>,
        <#if uiaction.getPSAppCounter?? && uiaction.getPSAppCounter()??>
        <#assign counter = uiaction.getPSAppCounter() />
        counterService:this.${counter.getCodeName()?lower_case}counterservice,
        <#if uiaction.getCounterId()??>counterId:"${uiaction.getCounterId()}",</#if>
        </#if>
        <#if uiaction.getNoPrivDisplayMode(view)??>
        noprivdisplaymode: ${uiaction.getNoPrivDisplayMode(view)},
        </#if>
        <#if uiaction.getDataAccessAction()??>
        dataaccaction:'${uiaction.getDataAccessAction()}',
        </#if>
        actiontarget:'<#if uiaction.getActionTarget()??>${uiaction.getActionTarget()}</#if>',
        visabled:true,
        disabled:false
        </#if>
        </#if>
        }<#if appViewLogic_has_next>,</#if>
        </#list>
        </#if>
    ];

    /**
     * 触发界面行为
     *
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public handleItemClick($event:any){
    <#if  ctrl.getPSAppViewLogics?? && ctrl.getPSAppViewLogics()??>
    <#list ctrl.getPSAppViewLogics() as appViewLogic>
        if(Object.is($event,'${appViewLogic.name}')){
            this.${appViewLogic.name}(null);
        }
    </#list>
    </#if>
    }
    </#if>

    <#if ctrl.getPortletType?? && ctrl.getPortletType()?? && ctrl.getPortletType() == "TOOLBAR" >
    <#assign toolbar = ctrl.getContentPSControl()/>
    ${P.getCtrlCode(toolbar, 'CONTROL.vue').code}
    </#if>

    /**
     * 是否自适应大小
     *
     * @returns {boolean}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    @Prop({default: false})public isAdaptiveSize!: boolean;

    /**
     * 获取多项数据
     *
     * @returns {any[]}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public getDatas(): any[] {
        return [];
    }

    /**
     * 获取单项树
     *
     * @returns {*}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public getData(): any {
        return {};
    }

    /**
     * 获取高度
     *
     * @returns {any[]}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    get getHeight(): any{
        if(!this.$util.isEmpty(this.height) && !this.$util.isNumberNaN(this.height)){
            if(this.height == 0){
                return 'auto';
            } else {
                return this.height+'px';
            }
        } else {
  <#if ctrl.getHeight?? && ctrl.getHeight() gt 0>
            return '${ctrl.getHeight()?c}px';
  <#else>
            return 'auto';
  </#if>
        }
    }

    /**
     * vue 生命周期
     *
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public created() {
        this.afterCreated();
    }

    /**
     * 执行created后的逻辑
     *
     *  @memberof ${srfclassname('${ctrl.codeName}')}Base
     */    
    public afterCreated(){
        if (this.viewState) {
            this.viewStateEvent = this.viewState.subscribe(({ tag, action, data }) => {
                if(Object.is(tag, "all-portlet") && Object.is(action,'loadmodel')){
                   this.calcUIActionAuthState(data);
                }
                if (!Object.is(tag, this.name)) {
                    return;
                }
                const refs: any = this.$refs;
                Object.keys(refs).forEach((_name: string) => {
                    this.viewState.next({ tag: _name, action: action, data: data });
                });
            });
        }
    }

    /**
     * vue 生命周期
     *
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public destroyed() {
        this.afterDestroy();
    }

    /**
     * 执行destroyed后的逻辑
     *
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public afterDestroy() {
        if (this.viewStateEvent) {
            this.viewStateEvent.unsubscribe();
        }
        <#if destroyed_block??>
        ${destroyed_block}
        </#if>
    }

    /**
     * 计算界面行为权限
     *
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public calcUIActionAuthState(data:any = {}) {
        //  如果是操作栏，不计算权限
        if(this.portletType && Object.is('actionbar', this.portletType)) {
            return;
        }
        let _this: any = this;
        let uiservice: any = _this.appUIService ? _this.appUIService : new UIService(_this.$store);
        if(_this.uiactionModel){
            ViewTool.calcActionItemAuthState(data,_this.uiactionModel,uiservice);
        }
    }

    <#if ctrl.getPortletType() != 'ACTIONBAR'>
    <#if ctrl.getPSUIActionGroup?? && ctrl.getPSUIActionGroup()?? && ctrl.getPSUIActionGroup().getPSUIActionGroupDetails()??>
    <#assign UIActionDetails=ctrl.getPSUIActionGroup().getPSUIActionGroupDetails() />
    /**
     * 执行界面行为
     *
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public uiAction(tag:string,event:any){
    <#list UIActionDetails as uiactiondetail>
        if(Object.is(tag,'${uiactiondetail.getName()?lower_case}')){
            this.${ctrl.getName()?lower_case}_${uiactiondetail.getName()?lower_case}_click(null,tag,event);
        }
    </#list>
    }
    </#if>
    </#if>

    /**
     * 刷新
     *
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public refresh(args?: any) {
      <#if ctrl.getPortletType?? && ctrl.getPortletType()?? && ctrl.getPortletType() == "VIEW">
      this.viewState.next({ tag: '${ctrl.getPortletPSAppView().getName()}', action: 'refresh', data: args });
      </#if>
      <#if ctrl.getPortletType?? && ctrl.getPortletType()?? && (ctrl.getPortletType() == "CHART" || ctrl.getPortletType() == "LIST")>
      this.viewState.next({ tag: '${ctrl.getContentPSControl().getName()}', action: 'refresh', data: args });
      </#if>
    }

<#ibizinclude>
../@MACRO/CONTROL/CONTROL_BOTTOM-BASE.vue.ftl
</#ibizinclude>
</#if>